import React from 'react';
import QRCode from 'qrcode-react';
/**
 * 加载公共组件
 * */
import MainSection from '../../components/MainSection/MainSection';
import Avatar from '../../components/Avatar/Avatar';

/**
 * 加载样式或图片文件
 * */
import './sass/myQrcode.scss';
import defaultAvatar from'../_common_img/sponsor/head.png';


class MyQrcode extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            loadingVisible:false
        };
    }
    render() {
        const {actions, user} = this.props;
        let userInfo = user.userInfo;
        let QRCodeValue = {
            data: userInfo.data,
            type: userInfo.type
        };
        return (
            <MainSection className="my-qrcode" title="我的二维码">
                <div className="shadow">
                    <div className="qrcode-box">
                        <Avatar src={userInfo.avatar || defaultAvatar}/>
                        <p className="name">{userInfo.name || userInfo.phone}</p>
                        <div className="qrcode">
                            <QRCode value={ JSON.stringify(QRCodeValue) }/>
                        </div>
                        <p className="tip">每个二维码都是私人定制，您值得拥有</p>
                    </div>
                </div>
            </MainSection>
        );
    }
}

export default MyQrcode;